/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.anhanguera.tcc.model;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Diego
 */
@Entity
@Table(name = "tb_aeronave")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Aeronave.findAll", query = "SELECT a FROM Aeronave a"),
    @NamedQuery(name = "Aeronave.findByIdVeiculo", query = "SELECT a FROM Aeronave a WHERE a.idVeiculo = :idVeiculo"),
    @NamedQuery(name = "Aeronave.findByNmVeiculo", query = "SELECT a FROM Aeronave a WHERE a.nmVeiculo = :nmVeiculo"),
    @NamedQuery(name = "Aeronave.findByTxVeiculo", query = "SELECT a FROM Aeronave a WHERE a.txVeiculo = :txVeiculo"),
    @NamedQuery(name = "Aeronave.findByNmMarca", query = "SELECT a FROM Aeronave a WHERE a.nmMarca = :nmMarca"),
    @NamedQuery(name = "Aeronave.findByNmModelo", query = "SELECT a FROM Aeronave a WHERE a.nmModelo = :nmModelo"),
    @NamedQuery(name = "Aeronave.findByAnoFabricacao", query = "SELECT a FROM Aeronave a WHERE a.anoFabricacao = :anoFabricacao")})
public class Aeronave implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_VEICULO")
    private Integer idVeiculo;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "NM_VEICULO")
    private String nmVeiculo;
    @Size(max = 256)
    @Column(name = "TX_VEICULO")
    private String txVeiculo;
    @Size(max = 45)
    @Column(name = "NM_MARCA")
    private String nmMarca;
    @Size(max = 45)
    @Column(name = "NM_MODELO")
    private String nmModelo;
    @Column(name = "ANO_FABRICACAO")
    @Size(max = 4)
    private String anoFabricacao;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codVeiculo")
    private List<ComprovanteEntrega> comprovanteEntregaList;

    public Aeronave() {
    }

    public Aeronave(Integer idVeiculo) {
        this.idVeiculo = idVeiculo;
    }

    public Aeronave(Integer idVeiculo, String nmVeiculo) {
        this.idVeiculo = idVeiculo;
        this.nmVeiculo = nmVeiculo;
    }

    public Integer getIdVeiculo() {
        return idVeiculo;
    }

    public void setIdVeiculo(Integer idVeiculo) {
        this.idVeiculo = idVeiculo;
    }

    public String getNmVeiculo() {
        return nmVeiculo;
    }

    public void setNmVeiculo(String nmVeiculo) {
        this.nmVeiculo = nmVeiculo;
    }

    public String getTxVeiculo() {
        return txVeiculo;
    }

    public void setTxVeiculo(String txVeiculo) {
        this.txVeiculo = txVeiculo;
    }

    public String getNmMarca() {
        return nmMarca;
    }

    public void setNmMarca(String nmMarca) {
        this.nmMarca = nmMarca;
    }

    public String getNmModelo() {
        return nmModelo;
    }

    public void setNmModelo(String nmModelo) {
        this.nmModelo = nmModelo;
    }

    public String getAnoFabricacao() {
        return anoFabricacao;
    }

    public void setAnoFabricacao(String anoFabricacao) {
        this.anoFabricacao = anoFabricacao;
    }

    @XmlTransient
    public List<ComprovanteEntrega> getComprovanteEntregaList() {
        return comprovanteEntregaList;
    }

    public void setComprovanteEntregaList(List<ComprovanteEntrega> comprovanteEntregaList) {
        this.comprovanteEntregaList = comprovanteEntregaList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idVeiculo != null ? idVeiculo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Aeronave)) {
            return false;
        }
        Aeronave other = (Aeronave) object;
        if ((this.idVeiculo == null && other.idVeiculo != null) || (this.idVeiculo != null && !this.idVeiculo.equals(other.idVeiculo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.anhanguera.tcc.model.Aeronave[ idVeiculo=" + idVeiculo + " ]";
    }

}
